#!/usr/bin/env node

const http = require('http');

http.createServer((req,res)=>{
  if(req.url==='/'){
    const html = '<html><head><meta charset="utf8"></head><body><h1>hello 王顶</h1></body></html>';
    res.setHeader('Content-Type','text/html');
    res.setHeader('Content-Length',`${Buffer.byteLength(html)}`);
   /* res.writeHead(200,{
      'Content-Type':'text/html',
      'Content-Length':Buffer.byteLength(html)
    });*/
    res.end(html);
  }else{
    res.statusCode=404;
    res.setHeader('Content-Type','text/plain');
    res.end('Resource not found');
  }
}).listen(3000);
